#include<iostream>
#include<fstream>
using namespace std;
ifstream::pos_type size;
char *memblock;
int main() {
  //ifstream file ("t1.txt", ios::in|ios::binary|ios::ate);
  ifstream file ("t1.txt", ios::in|ios::ate);
     if(file.is_open()){	
	ofstream foo;
	foo.open("t1.txt");
	foo << "hello my world\n";
	foo << foo;
	foo.close();
	
	size =file.tellg();
	memblock = new char [size];
	file.seekg (0, ios::beg);
	file.read (memblock, size);
	file.close();
	cout << "the content of file in memory \n";
	int c;
	for(c=0;c<size;c++){
		cout << c << memblock[c] << "\n";
	}
	delete[] memblock;
      }
      else{
	cout << "cannot open file\n";
      } 
   return 0;
}

